package com.ht.controller;

import com.ht.bean.Student;
import com.ht.service.StuhdayCountService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stuhdaycount")
public class StuhdayCountController {

    @Resource
    private StuhdayCountService stuhdayCountService;

    //去教师端通知公告页面
    @RequestMapping("/gostuhdaycountList")
    public String tonotice(){
        return "stuhdaycount";
    }

    @RequestMapping("/stuhdaycountList")
    @ResponseBody
    public Map stuhdaycountList(String stuName,Integer page, Integer limit){
        Map map = new HashMap();
        List<Map> list = stuhdayCountService.countStuHlday(stuName,(page-1)*limit,limit);
        map.put("code",0);
        map.put("msg","成功");
        map.put("count",stuhdayCountService.limitStuHlday(stuName));//总页数
        map.put("data",list);
        return map;

    }

    @RequestMapping("/countMap")
    @ResponseBody
    public Map countMap(){
        Map map = new HashMap();
        List<String> list = new ArrayList<>();
        List<Integer> list1 = new ArrayList<>();
        List<Student> students = stuhdayCountService.countMapName();
        for (Student studentes : students){
            list.add(studentes.getStuname());
            list1.add(studentes.getStuId());
        }

        map.put("stuName",list);
        map.put("countNum",list1);
        System.out.println(list.toString());
        System.out.println(list1.toString());

        return map;
    }

}
